sampler GlowSource : register(s0);
// uniform extern float blurSize;

float offsets[] =
{
	0.0f,
	0.005f,
	0.01166667f,
	0.01833333f,
	0.025f,
	0.03166667f,
	0.03833333f,
	0.045,
};

float weights[] =
{
	0.0530577f,
	0.1028506f,
	0.09364651f,
	0.0801001f,
	0.06436224f,
	0.04858317f,
	0.03445063f,
	0.02294906f
};

float gBlurSize = 0.4f;
float gGlowStrength = 4.0f;

float4 GlowBlurHorizontalPS2(float2 texCoord : TEXCOORD0) : COLOR0
{
	float4 value = 0.0f;
	for(int i=0 ; i<6 ; i++)
	{
		value += weights[i] * gGlowStrength * tex2D(GlowSource, texCoord + float2(offsets[i] * gBlurSize, 0.0f));
		value += weights[i] * gGlowStrength * tex2D(GlowSource, texCoord - float2(offsets[i] * gBlurSize, 0.0f));
	}
 
    return value;
}

float4 GlowBlurVerticalPS2(float2 texCoord : TEXCOORD0) : COLOR0
{
    float4 value = 0.0f;
	for(int i=0 ; i<6 ; i++)
	{
		value += weights[i] * gGlowStrength* tex2D(GlowSource, texCoord + float2(0.0f, offsets[i] * gBlurSize));
		value += weights[i] * gGlowStrength * tex2D(GlowSource, texCoord - float2(0.0f, offsets[i] * gBlurSize));
	}
 
    return value;
}

float4 GlowBlurHorizontalPS(float2 texCoord : TEXCOORD0) : COLOR0
{
    float4 value = tex2D(GlowSource, texCoord) * 1.0f;
    
    float a = 1.0f / 1024.0f;
    value += tex2D(GlowSource, texCoord + float2(3.0f/1024.0f, 0.0f)) * 0.4f;
    value += tex2D(GlowSource, texCoord - float2(3.0f/1024.0f, 0.0f)) * 0.4f;
    
    value += tex2D(GlowSource, texCoord + float2(5.0f/1024.0f, 0.0f)) * 0.3f;
    value += tex2D(GlowSource, texCoord - float2(5.0f/1024.0f, 0.0f)) * 0.3f;
    
    value += tex2D(GlowSource, texCoord + float2(7.0f/1024.0f, 0.0f)) * 0.2f;
    value += tex2D(GlowSource, texCoord - float2(7.0f/1024.0f, 0.0f)) * 0.2f;
    
    value += tex2D(GlowSource, texCoord + float2(9.0f/1024.0f, 0.0f)) * 0.16f;
    value += tex2D(GlowSource, texCoord - float2(9.0f/1024.0f, 0.0f)) * 0.16f;
    
    value += tex2D(GlowSource, texCoord + float2(11.0f/1024.0f, 0.0f)) * 0.12f;
    value += tex2D(GlowSource, texCoord - float2(11.0f/1024.0f, 0.0f)) * 0.12f;
    
    value += tex2D(GlowSource, texCoord + float2(13.0f/1024.0f, 0.0f)) * 0.09f;
    value += tex2D(GlowSource, texCoord - float2(13.0f/1024.0f, 0.0f)) * 0.09f;
    
    
    
 
    return value;
}

float4 GlowBlurVerticalPS(float2 texCoord : TEXCOORD0) : COLOR0
{
    float4 value = tex2D(GlowSource, texCoord) * 1.0f;
    
    value += tex2D(GlowSource, texCoord + float2(0.0f, 3.0f/768.0f)) * 0.4f;
    value += tex2D(GlowSource, texCoord - float2(0.0f, 3.0f/768.0f)) * 0.4f;

	value += tex2D(GlowSource, texCoord + float2(0.0f, 5.0f/768.0f)) * 0.3f;
    value += tex2D(GlowSource, texCoord - float2(0.0f, 5.0f/768.0f)) * 0.3f;
    
    value += tex2D(GlowSource, texCoord + float2(0.0f, 7.0f/768.0f)) * 0.2f;
    value += tex2D(GlowSource, texCoord - float2(0.0f, 7.0f/768.0f)) * 0.2f;
    
    value += tex2D(GlowSource, texCoord + float2(0.0f, 9.0f/768.0f)) * 0.16f;
    value += tex2D(GlowSource, texCoord - float2(0.0f, 9.0f/768.0f)) * 0.16f;
    
    value += tex2D(GlowSource, texCoord + float2(0.0f, 11.0f/768.0f)) * 0.12f;
    value += tex2D(GlowSource, texCoord - float2(0.0f, 11.0f/768.0f)) * 0.12f;
    
    value += tex2D(GlowSource, texCoord + float2(0.0f, 13.0f/768.0f)) * 0.09f;
    value += tex2D(GlowSource, texCoord - float2(0.0f, 13.0f/768.0f)) * 0.09f;
 
    return value;
}

technique GlowBlurHorizontal
{
    pass Pass1
    {
        PixelShader = compile ps_2_0 GlowBlurHorizontalPS2();
    }
}

technique GlowBlurVertical
{
    pass Pass1
    {
        PixelShader = compile ps_2_0 GlowBlurVerticalPS2();
    }
}
